﻿using KinonekoSoftware.Studio.Pages.Instances.Core;

namespace KinonekoSoftware.Studio.Pages.Instances
{
    partial class XGInstanceEditorViewModel
    {
        private readonly Stack<XGEditorLayoutMode> _layoutModeStack;

        private PreviewContent _preview;
        private PartialContent _partial;

        private bool _isHangAroundMode;
        private bool _isDeepDiveMode;
        private bool _isWireframeMode;


        private void InvalidateLayoutMode()
        {
            _layoutModeStack.Push(XGEditorLayoutMode.Hangaround);
            PerformanceLayoutMode();
        }

        public void PerformanceLayoutMode()
        {
            //
            // 注意:
            // 该方法只用于呈现LayoutMode的改变，不会检查Preview属性
            var mode = _layoutModeStack.Peek();

            if (mode == XGEditorLayoutMode.Hangaround)
            {
                IsHangAroundMode = true;
                IsWireframeMode        = false;
                IsDeepDiveMode   = false;
            }
            else if (mode == XGEditorLayoutMode.DeepDive)
            {
                //
                // DeepDive 模式，使用的是CompareLayout
                IsHangAroundMode = false;
                IsWireframeMode  = false;
                IsDeepDiveMode   = true;
            }
            else
            {

                IsHangAroundMode = false;
                IsWireframeMode  = true;
                IsDeepDiveMode   = false;
            }
        }

        private void DoPushPaintingWireframeCommand()
        {
            _layoutModeStack.Push(XGEditorLayoutMode.PaintingWireframe);
            PerformanceLayoutMode();
        }

        private void CreatePaintingDeepDiveLayout()
        {
            //
            // 首先要给定一个
            Preview = new PaintingPreviewContent(this);
            Partial = new DeepDivePartialContent(this);

        }


        /// <summary>
        /// 获取或设置 <see cref="Partial"/> 属性。
        /// </summary>
        public PartialContent Partial
        {
            get => _partial;
            set => SetValue(ref _partial, value);
        }
        /// <summary>
        /// 获取或设置 <see cref="Preview"/> 属性。
        /// </summary>
        public PreviewContent Preview
        {
            get => _preview;
            set => SetValue(ref _preview, value);
        }

        /// <summary>
        /// 获取或设置 <see cref="IsWireframeMode"/> 属性。
        /// </summary>
        public bool IsWireframeMode
        {
            get => _isWireframeMode;
            set => SetValue(ref _isWireframeMode, value);
        }

        /// <summary>
        /// 获取或设置 <see cref="IsDeepDiveMode"/> 属性。
        /// </summary>
        public bool IsDeepDiveMode
        {
            get => _isDeepDiveMode;
            set => SetValue(ref _isDeepDiveMode, value);
        }

        /// <summary>
        /// 获取或设置 <see cref="IsHangAroundMode"/> 属性。
        /// </summary>
        public bool IsHangAroundMode
        {
            get => _isHangAroundMode;
            set => SetValue(ref _isHangAroundMode, value);
        }

        /*
         * Dig -> 意味
         *
         * DeepDive -> 用于表示粗布
         */

        public ICommandEX PopMenuCommand               { get; }
        public ICommandEX PushPaintingWireframeCommand { get; }
    }
}